<?php

namespace App\Admin\Controllers;

use App\paypal;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class PaypalController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\paypal';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new paypal());

        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();

            // 在这里添加字段过滤器
            $filter->like('Name', 'PP注册资料公司名称');

        });

        $grid->column('Name', __('PP注册资料公司名称'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('masspay', __('masspay'));
        $grid->column('Email', __('paypal邮箱'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Pwd', __('密码'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Phone', __('手机号'));
        $grid->column('Status', __('状态'));
        $grid->column('Account1', __('子账号1'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Pwd1', __('密码1'));
        $grid->column('Account2', __('子账号2'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Pwd2', __('密码2'));
        $grid->column('Shop', __('使用店铺'));
        $grid->column('Platgrid', __('平台'));
        $grid->column('Remarks', __('备注'))->display(function($text) {
            return str_limit($text, 12, '...');
        });


        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(paypal::findOrFail($id));


        $show->field('Name', __('PP注册资料公司名称'));
        $show->field('masspay', __('masspay'));
        $show->field('Email', __('paypal邮箱'));
        $show->field('Pwd', __('密码'));
        $show->field('Phone', __('手机号'));
        $show->field('Status', __('状态'));
        $show->field('Account1', __('子账号1'));
        $show->field('Pwd1', __('密码1'));
        $show->field('Account2', __('子账号2'));
        $show->field('Pwd2', __('密码2'));
        $show->field('Shop', __('使用店铺'));
        $show->field('Platform', __('平台'));
        $show->field('Remarks', __('备注'));


        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new paypal());


        $form->text('Name', __('PP注册资料公司名称'));
        $form->text('masspay', __('masspay'));
        $form->email('Email', __('paypal邮箱'));
        $form->password('Pwd', __('密码'));
        $form->mobile('Phone', __('手机号'));
        $form->text('Status', __('状态'));
        $form->text('Account1', __('子账号1'));
        $form->password('Pwd1', __('密码1'));
        $form->text('Account2', __('子账号2'));
        $form->password('Pwd2', __('密码2'));
        $form->text('Shop', __('使用店铺'));
        $form->text('Platform', __('平台'));
        $form->text('Remarks', __('备注'));


        return $form;
    }
}
